package binary_tree.leetcode.medium;

/**
 * @author bruin_du
 * @description 二叉树剪枝
 * @date 2022/8/14 19:51
 **/
public class OfferII047_PruneTree {
    public TreeNode pruneTree(TreeNode root) {
        if (root == null) return null;
        root.left = pruneTree(root.left);
        root.right = pruneTree(root.right);
        if (root.left == null && root.right == null && root.val == 0) return null;
        return root;
    }
}
